home *** CD-ROM | disk | FTP | other *** search
- Path: rain.fr!world-net!usenet
- From: Frederic LACHASSE <lachass@worldnet.fr>
- Newsgroups: comp.lang.c++
- Subject: Re: Saving a file from C++ app to ANSI windows format.
- Date: Sun, 17 Mar 1996 07:35:16 +0000
- Organization: World-Net information exchange, Internet provider.
- Message-ID: <VA.0000006e.00028fb5@fred>
- References: <4ibc80$94o@mn5.swip.net>
- Reply-To: lachass@worldnet.fr
- NNTP-Posting-Host: client122.sct.fr
- X-Newsreader: Virtual Access by Ashmount Research Ltd, http://www.ashmount.com
-
- In article <4ibc80$94o@mn5.swip.net>, m-27103@mailbox.swipnet.se (Walter
- Lam) wrote:
- >
- > A fellow worker of mine asked me to post this question... I myself don't
- > know much about it, so I hope someone on the Net does.....
- >
- > How can I save a file from a C++ app as an ANSI Windows format? The C++
- > app is a DOS app.
- >
-
- I suppose you want to translate some text from a DOS code page 437 (DOS US)
- or 850 (DOS multinational) (or perhaps another more exotic) to the ISO8859
- code page (I think it's 1004) used by Windows 3.x.
-
- The simple way is by creating a conversion table. You can use half a table,
- because the first 128 codes doesn't need to be translated.
-
- Example of code:
-
- char PC2ISO[128] = {
- // here is the important work: find a PC437 or PC850 character set table
- // and find the corresponding code in the ISO table.
-
-
- };
-
- void translate(const char *from, size_t size, char *to)
- {
- while (size)
- {
- *to = (char)((unsigned char)*from < 128 ? *from : PC2ISO[*from - 128]);
- ++to;
- ++from;
- --size;
- }
- }
-
- I hope this'll help.
-
- Frederic LACHASSE (ECP 86)
- CompuServe: 100530,2005
- Internet: lachass@worldnet.fr
-
-